"use client"; import { ChangeEvent, FC, PropsWithChildren, useMemo, useState } from "react"; import clsx from "clsx"; import Link from "next/link"; import ButtonOwn from "@/components/ButtonOwn"; import "./style.scss"; /** * @description 登录注册From表单 * @param {string} type 使用类型 * @param {(params: any) => void} callbackFun 回调方法 */ export interface FromComProps { type?: string; text?: string; callbackFun?: (params: any) => void; } const FromCom: FC> = ({type = 'login', callbackFun}) => { let [pwdVisible, setPwdVisible] = useState(false) const spanClassName = clsx("iconfont", { "icon-kejian": pwdVisible, "icon-bukejian": !pwdVisible, }); let [fromParam, setFromParam] = useState({ userPhone: '', pwd: '' }) const activeCls = useMemo(() => { let { userPhone, pwd } = fromParam if (userPhone && userPhone.length==11 && pwd && pwd.length>6) { return true } return false }, [fromParam]); const setInputVal = (e: ChangeEvent, propsName: string) => { setFromParam({ ...fromParam, [propsName]: e.target.value }) } const verifyPwd = (e: any) => { let pwd = e.target.value || ''; pwd.replaceAll(/[^a-zA-Z0-9_-]/g, '') setFromParam({ ...fromParam, pwd }) console.log('fromParam', fromParam.pwd) } const submitRequest = () => { activeCls && callbackFun!(fromParam) } return (
+55 setInputVal(e, 'userPhone') } placeholder="Número de Celular" maxLength={11} />
setInputVal(e, 'pwd') } onInput={verifyPwd} placeholder="Senha" maxLength={12}/> setPwdVisible(!pwdVisible)}>
O número de telefone não existe.
{type == 'login'? 'Login' : 'Criar conta'}
{ type == 'login' ? ( <> Esqueci minha senha? Criar Conta Nova ) : Já tem uma conta? Log in }
); }; export default FromCom;